package com.example.day03_mvp.model;

import com.example.day03_mvp.base.BaseModel;
import com.example.day03_mvp.base.BaseObserver;
import com.example.day03_mvp.bean.WanBean;
import com.example.day03_mvp.not.ApiService;
import com.example.day03_mvp.not.HttpUlist;
import com.example.day03_mvp.not.RxUlist;

import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;

public class WanModel extends BaseModel {
   public void addModel(WanCallBack callBack){
       ApiService apiServer = new HttpUlist().getApiServer(ApiService.url, ApiService.class);
       Observable<WanBean> getdata = apiServer.getdata();
       getdata.compose(RxUlist.RxObservableTransformer())
               .subscribe(new BaseObserver<WanBean>(this) {
                   @Override
                   protected void onFali(String message) {
                       callBack.onFali(message);
                   }

                   @Override
                   protected void onSuccess(WanBean wanBean) {
                        callBack.onSuccess(wanBean);
                   }

                   @Override
                   public void onSubscribe(Disposable d) {

                   }
               });
   }
}
